package com.jeesite.modules.dataScreen.ssm;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
@ApiModel("短信发送参数")
@Accessors(chain = true)
public class SmsSendParams {
    @ApiModelProperty("企业编号")
    private String SpCode;
    @ApiModelProperty("用户名")
    private String LoginName;
    @ApiModelProperty("接口密钥")
    private String Password;
    @ApiModelProperty("短信内容")
    private String MessageContent;
    @ApiModelProperty("手机号")
    private String[] UserNumber;
    @ApiModelProperty("模板编号")
    private String templateId;
    @ApiModelProperty("流水号")
    private String SerialNumber;
    @ApiModelProperty("预约发送时间，为空则立即发送,格式:yyyyMMddHHmmss")
    private String ScheduleTime;
    @ApiModelProperty("提交时检测方式,固定1")
    private String f;


    @Override
    public String toString() {
        Map<String, Object> map = BeanUtil.beanToMap(this, false, true);
        //特殊处理号码数组
        String[] userNumber = (String[])map.get("UserNumber");
        if (userNumber != null) {
            map.put("UserNumber", StrUtil.join(",", userNumber));
        }
        List<String> list = map.entrySet().stream()
                .map(item -> item.getKey() + "=" + item.getValue().toString())
                .collect(Collectors.toList());
        return StrUtil.join("&", list);
    }

}
